package com.asset.dispoal.menu.service.commom;

import com.asset.dispoal.menu.domain.db.mapper.GbMenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.springboot.protocol.Result;

import java.util.List;

/**
 * @author qr
 * @date 2022/3/1$
 */
@Component
public class SelectMenuCommand implements BaseCommand<List<String>, Result> {


    @Autowired
    GbMenuMapper menuMapper;


    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public Result execute(List<String> list) {
        menuMapper.updateSelectMenu(null, "0");
        menuMapper.updateSelectMenu(list, "1");
        return Result.ok();
    }
}
